home *** CD-ROM | disk | FTP | other *** search
- Path: news.gate.net!rdl-ilps-rxh2
- From: rmcinnis@gate.net (Robert B McInnis)
- Newsgroups: comp.lang.c++
- Subject: Re: Q : pointer to member function
- Date: 11 Apr 1996 17:36:24 GMT
- Organization: 9th Bit Software
- Message-ID: <4kjfuo$2gm@news.gate.net>
- References: <4kd9lh$q3q@imag.imag.fr>
- NNTP-Posting-Host: miafl3-48.gate.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
-
- For pointers to member functions, refer to Stroustrup v2 pgs. 166, 502. For a
- quick solution:
-
- typedef void (Foo::FooFunc*)() ;
-
- class Foo
- {
- virtual void calc() ;
- virtual void doit() ;
- } ;
-
-
- FooFunc func1, func2 ;
- Foo f1 ;
-
- func1 = &Foo::calc ;
- func2 = &Foo::doit ;
-
- (f1->*func1)() ; // same as f1->calc()
- (f1->*func2)() ; // same as f1->doit()
-
- Hope this helps,
-
- Rob
-
- ps: Look for my posts on Observer/Callback for more info/uses on this
- technique.
-
- -----------------------------
- Robert McInnis
- 9th Bit Software
- (eMail) rmcinnis@gate.net
- (web ) http://www.gate.net/~rmcinnis
-
-
-
-
-